/* Copyright(C) 2006-2008 Dave Sexton  *
 * http://www.codeplex.com/aip         *
 * http://www.codeplex.com/aip/license *
 ***************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.Design;
using System.ComponentModel;
using System.Web.UI.WebControls;
using System.IO;
using System.Web.UI;
using System.Web.UI.Design.WebControls;
using System.Security.Permissions;
using DaveSexton.Web.Controls.Resources;

namespace DaveSexton.Web.Controls.Design
{
	/// <summary>
	/// Graphic designer for the <see cref="AutoInputProtectionControl"/> web control.
	/// </summary>
	[PermissionSet(SecurityAction.Demand, Unrestricted = true)]
	internal sealed class AutoInputProtectionControlDesigner : CompositeControlDesigner
	{
		#region Public Properties
		/// <summary>
		/// Gets a collection of template names from which a user may choose to edit a particular template in the designer.
		/// </summary>
		public override System.Web.UI.Design.TemplateGroupCollection TemplateGroups
		{
			get
			{
				TemplateGroupCollection groups = new TemplateGroupCollection();
				TemplateGroup group = new TemplateGroup("Contents");
				TemplateDefinition template = new TemplateDefinition(this, "Contents", Component, "Template");

				group.AddTemplateDefinition(template);

				groups.Add(group);

				return groups;
			}
		}
		#endregion

		#region Private / Protected
		private AutoInputProtectionControl control;
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="AutoInputProtectionControlDesigner" /> class.
		/// </summary>
		public AutoInputProtectionControlDesigner()
		{
		}
		#endregion

		#region Methods
		/// <summary>
		/// Initializes the designer for the specified <paramref name="component"/>.
		/// </summary>
		/// <param name="component">An instance of <see cref="AutoInputProtectionControl"/> to be designed.</param>
		/// <exception cref="InvalidOperationException">The specified <paramref name="component"/> is not an <see cref="AutoInputProtectionControl"/>.</exception>
		public override void Initialize(IComponent component)
		{
			control = component as AutoInputProtectionControl;

			if (control == null)
				throw new InvalidOperationException(Errors.AIPControlDesigner_InvalidComponentType);

			base.Initialize(component);

			SetViewFlags(System.Web.UI.Design.ViewFlags.TemplateEditing, true);
		}
		#endregion
	}
}
